package com.example.demo.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.example.demo.dto.EmployeeDetailResponseDto;
import com.example.demo.dto.LoginRequestDto;
import com.example.demo.entity.EmployeeEntity;
import com.example.demo.mapper.EmployeeMapper;
import com.example.demo.service.EmployeeService;

/**
 * 社員管理 サービス
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

	@Resource
	private EmployeeMapper employeeMapper;

	/**
	 * 詳細
	 *
	 * @param requestDto
	 * @return DetailResponseDto
	 */
	public EmployeeDetailResponseDto empDetail(String employeeNumber) {

		// 社員情報を詳細する取得
		EmployeeEntity employeeEntity = employeeMapper.empDetail(employeeNumber);
		EmployeeDetailResponseDto detailResponseDto = new EmployeeDetailResponseDto();
		// 検索結果判定
		if (employeeEntity == null) {
			detailResponseDto.setProcessingResult("0");
		}else {
			BeanUtils.copyProperties(employeeEntity, detailResponseDto);
			detailResponseDto.setProcessingResult("1");
		}
		return detailResponseDto;
	}

	/**
	 * query empInfo all
	 */
	public List<EmployeeDetailResponseDto> empInfo() {
		List<EmployeeDetailResponseDto> empInfoAll= employeeMapper.empInfo();
		return empInfoAll;
	}
}
